﻿Imports AUtility

Partial Public Class Igraci
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        GetIgraci()
        If (Session("UserId") IsNot Nothing) Then
            hypLogin.Visible = False
        Else
            hypLogin.Visible = True
        End If
    End Sub

    Private Sub GetIgraci()
        'Dim selectStr As String = String.Format("SELECT IgracId, Ime, Prezime, Mobitel, Mail FROM Igrac ORDER BY Ime")
        Dim selectStr As String = String.Format("SELECT IgracId, Ime, Prezime FROM Igrac ORDER BY Ime")

        If (ddlIgraci.SelectedItem.Text = "Tekuća sezona") Then
            selectStr = String.Format("SELECT IgracId, Ime, Prezime, Mobitel, Mail FROM Igrac WHERE IgracId IN (SELECT IgracId FROM SezonaLigaIgrac WHERE SezonaId = {0} ) ORDER BY Ime", GlobalTenisLiga.TekucaSetonaId)
        End If
        gvIgraci.DataSource = DataAccess.GetDataTable(GlobalTenisLiga.ConnectionString, selectStr)
        gvIgraci.DataBind()
    End Sub

    Protected Sub ddlIgraci_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlIgraci.SelectedIndexChanged
        GetIgraci()
    End Sub

    Protected Sub gvIgraci_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gvIgraci.SelectedIndexChanged
        Dim row As GridViewRow = gvIgraci.SelectedRow
    End Sub

    Protected Sub gvIgraci_RowEditing(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gvIgraci.RowEditing
        Dim igracId As String = gvIgraci.DataKeys(e.NewEditIndex).Value.ToString()
        Response.Redirect("PlayerInfo.aspx?IgracId=" + igracId)
    End Sub

    
    Protected Sub gvIgraci_RowDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvIgraci.RowDataBound
        'If (e.Row.RowType = DataControlRowType.DataRow) Then
        'If (Session("UserId") Is Nothing) Then
        '    e.Row.Cells(2).Text = String.Empty
        '    e.Row.Cells(3).Text = String.Empty
        '    e.Row.Cells(4).Text = String.Empty
        'End If

        'End If
    End Sub

    Protected Sub gvIgraci_DataBound(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gvIgraci.DataBound
        If (Session("UserId") Is Nothing) Then
            gvIgraci.Columns(2).Visible = False
            gvIgraci.Columns(3).Visible = False
            gvIgraci.Columns(4).Visible = False
        End If
    End Sub
End Class